﻿function BindServerDatatable(table, url, aoColumns, data) {
    $(table).dataTable({
        "iDisplayLength": 5,
        "aLengthMenu": [5, 10, 25, 50, 100], 
        
        "bServerSide": true,
        "sAjaxSource": url,
        "bProcessing": true,
        "bDestroy": true,
        "bJQueryUI": false,
        "sPaginationType": "full_numbers",
        
        "aaSorting": [],
        "aoColumns": aoColumns,
        "fnServerParams": function (aoData) {
            //aoData.push({ "name": "more_data", "value": "my_value" });
        }
    });
}

function ConvertSerializedate(value) {
    var e = value.replace('/Date(', '').replace(')/', '')
    var d = new Date(parseInt(e));
    //debugger;
    //d = DPGlobal.parseDate(d, 'd M, yy', 'en');
    //d = $.datepicker.formatDate('d M, yy', d);

    d = [d.getDate(), d.getMonth() + 1, d.getFullYear()].join('/');

    if (d == '1/1/1900')
        d = "";
    else
        return d;
    return d;
}
function AjaxCall(Pagepath) {
    var returnData = "";
    try {
        $.ajax({
            type: "POST",
            async: false,
            url: Pagepath,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                if (data != null) {
                    returnData = data;
                }
            },
            error: function (x, e) {
                alert("The call to the server side failed. " + x.responseText);
            }
        });
    } catch (e) {
        alert(e.ToString());
    }
    return returnData;
}


function AjaxCallWithData(Pagepath, Data) {

    var returnData = "";
    try {
        $.ajax({
            type: "POST",
            async: false,
            url: Pagepath,
            data:  Data ,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                if (data != null) {
                    returnData = data;
                }
            },
            error: function (x, e) {
                alert("The call to the server side failed. " + x.responseText);
            }
        });
    } catch (e) {
        alert(e.ToString());
    }
    return returnData;
}

